﻿using System.Linq;
using System.Web;
using System.Web.Http.Controllers;
using System.Web.Http.Filters;

namespace Zapi.Api.Filters
{
    /// <summary>
    /// 最先运行的Filter，被用作请求权限校验
    /// </summary>
    public class LoginAttribute : AuthorizationFilterAttribute
    {
        /// <summary>
        /// 不需要登录验证的控制器
        /// </summary>
        string[] url = { "admin" };

        public override void OnAuthorization(HttpActionContext actionContext)
        {
            var c = actionContext.RequestContext.RouteData.Values["controller"].ToString().ToLower();
            if (url.All(a => a != c))
            {
                var token = HttpContext.Current.Request.Headers["token"];
            }

        }
        
    }
}